import VueRouter from 'vue-router'
import Vue from 'vue'
Vue.use(VueRouter)
import login from '@/views/login/login.vue'
import layout from '@/layout/layout.vue'
import chart from '@/layout/layout/chart/chart.vue'
import bussness from '@/layout/layout/bussness/bussness.vue'
import quesBank from '@/layout/layout/quesBank/quesBank.vue'
import subject from '@/layout/layout/subject/subject.vue'
import userList from '@/layout/layout/userList/userList.vue'
import Nprogress from 'nprogress'
import "nprogress/nprogress.css"
const router = new VueRouter({
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      component: login
    },
    {
      path: '/layout',
      component: layout,
      children:[
        {
          path:'/layout',
          redirect: '/layout/layout/chart/chart',
         
        },
        {
          path:'/layout/layout/chart/chart',
          component:chart,
          meta:{
            title:'数据概览'
          }
        },
        {
          path:'/layout/layout/bussness/bussness',
          component:bussness,
          meta:{
            title:'企业列表'
          }
        },
        {
          path:'/layout/layout/quesBank/quesBank',
          component:quesBank,
          meta:{
            title:'题库列表'
          }
        },
        {
          path:'/layout/layout/subject/subject',
          component:subject,
          meta:{
            title:'学科列表'
          }
        },
        {
          path:'/layout/layout/userList/userList',
          component:userList,
          meta:{
            title:'用户列表'
          }
        },
      ]
    },
  ]
})
router.beforeEach((to,from,next)=>{
  console.log('to',to)
  console.log('from',from)
  Nprogress.start()
  next()

})
router.afterEach((to,from)=>{
  console.log('to',to)
  console.log('from',from)
  Nprogress.done()
  document.getElementById('title').innerText=to.meta.title
})
// 输出 router
export default router
